
import {defineStore} from 'pinia'
import {reqSortList,reqSortListId} from '@/api/modules/sort'
import type {sortCategory,sortBannerList,category2Data} from '@/api/modules/sort'
interface sortList {
    currentId:number | number[]
    navList:sortCategory[],
    currentCategory:sortBannerList[],
    category2List:category2Data[]
}
export const useSortInfo = defineStore('sortInfo',{
    state:()=>({
        currentId:11,
        navList : [],
        currentCategory :[],
        category2List:[]
    } as sortList
    ),
    actions:{
        async getSortData(){
            try {
              const res = await reqSortList()
            //   this.navList = res
            //  console.log(res);
            //  console.log(res.categoryL1List);
             this.navList = res.categoryL1List
            //  this.currentCategory = res.currentCategory
            this.currentCategory = res.currentCategory.bannerList
            this.category2List = res.categoryL2List
            // this.currentId = res.categoryL1List.
            // console.log(res.categoryL1List[0].id);
            let uid = res.categoryL1List.map(item => item.id)
            // console.log(uid);
            
            
            
            // this.currentId = 
            // console.log(this.currentId);    
              
            } catch (error) {
              
            }
        },
        // async getSortDataList(){
        //     try {
        //         const result = await reqSortListId(this.currentId)
                
        //     } catch (error) {
        //         console.log(222);
        //         console.log(error);
                
                
        //     }
        // }
    }

})